package com.xrz.sxm.aj.activity;

import android.app.LocalActivityManager;
import android.content.Intent;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TabHost;
import android.widget.RadioGroup.OnCheckedChangeListener;

import com.lidroid.xutils.view.annotation.ViewInject;
import com.xrz.sxm.aj.base.BaseAct;

public class LiaoFaChangshiActivity extends BaseAct {
	private String title;
	@ViewInject(R.id.rg)
	private RadioGroup radiogroup;
	@ViewInject(R.id.pager_weight_rb1)
	private RadioButton rb1;
	@ViewInject(R.id.pager_weight_rb2)
	private RadioButton rb2;
	@ViewInject(R.id.pager_weight_rb3)
	private RadioButton rb3;
	@ViewInject(R.id.pager_weight_rb4)
	private RadioButton rb4;
	@ViewInject(R.id.pager_weight_rb5)
	private RadioButton rb5;
	@ViewInject(R.id.tabhost)
	private TabHost mTabHost;
	private LocalActivityManager mActivityManager;

	@Override
	protected int setView() {
		return R.layout.layout_changshi;
	}

	@Override
	protected void init() {
		mActivityManager = new LocalActivityManager(this, true);
		mActivityManager.dispatchCreate(GetBundle());
		mTabHost.setup(mActivityManager);
		mTabHost.setup();
		mTabHost.addTab(mTabHost.newTabSpec("1").setIndicator("1")
				.setContent(new Intent(this, LiaoFaChangshi1Activity.class)));
		mTabHost.addTab(mTabHost.newTabSpec("2").setIndicator("2")
				.setContent(new Intent(this, LiaoFaChangshi2Activity.class)));
		mTabHost.addTab(mTabHost
				.newTabSpec("3")
				.setIndicator("3")
				.setContent(new Intent(this, LiaoFaChangshi3Activity.class)));
		mTabHost.addTab(mTabHost.newTabSpec("4").setIndicator("4")
				.setContent(new Intent(this, LiaoFaChangshi4Activity.class)));
		rb1.setChecked(true);
		radiogroup.setOnCheckedChangeListener(lis);
	}

	private OnCheckedChangeListener lis = new OnCheckedChangeListener() {

		public void onCheckedChanged(RadioGroup arg0, int arg1) {
			switch (arg1) {
			case R.id.pager_weight_rb1:
				rb1.setChecked(true);
				mTabHost.setCurrentTab(0);
				break;
			case R.id.pager_weight_rb2:
				rb2.setChecked(true);
				mTabHost.setCurrentTab(1);
				break;
			case R.id.pager_weight_rb3:
				rb3.setChecked(true);
				mTabHost.setCurrentTab(2);
				break;
			case R.id.pager_weight_rb4:
				rb4.setChecked(true);
				mTabHost.setCurrentTab(3);
				break;
			}
		}
	};

	@Override
	protected String setTopTitle() {
		title = getIntent().getStringExtra("type");
		return title;
	}

}
